package com.weiz.rabbitmq.controller;

import com.weiz.rabbitmq.entity.OrderInfo;
import com.weiz.rabbitmq.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/save")
    public String save() {
        OrderInfo order = new OrderInfo();
        order.setId("2005");
        order.setName("测试订单11");
        order.setMessageId(System.currentTimeMillis() + "$" + UUID.randomUUID().toString());
        try {
            orderService.createOrder(order);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "订单创建成功";
    }

}
